package com.lagou.demo.controller;

import com.lagou.demo.service.DemoService;
import com.lagou.edu.mvcframework.annotations.MyAutowired;
import com.lagou.edu.mvcframework.annotations.MyController;
import com.lagou.edu.mvcframework.annotations.MyRequestMapping;
import com.lagou.edu.mvcframework.annotations.Security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * TODO
 *
 * @author chenx
 * @date 2021/4/27
 */
@MyController
@MyRequestMapping("/demo")
public class DemoController {
    @MyAutowired
    private DemoService demoService;
    @MyRequestMapping("/query")
    public String query(HttpServletRequest request, HttpServletResponse response,String name) throws IOException {
        String query = demoService.query(name);
        System.out.println("DemoController>>name:"+name);
        response.getWriter();
        return query;
    }
    @Security("zhangsan,lisi")
    @MyRequestMapping("/securityQuery")
    public String securityQuery(HttpServletRequest request, HttpServletResponse response,String name) throws IOException {
        String query = demoService.query(name);
        System.out.println("DemoController>>name:"+name);
        response.getWriter().write(query);
        return query;
    }


}
